#include <iostream>
#include "FileHelp.h"
#include "pcapParse.h"


int main()
{
	// 输入rtp 流，输出264 

	uint16_t lastSeq = 0;
	int index = 0;

	char* buf = new char[1024 * 128];

	//ReadFile::GetInstans().RFile((char*)"tcp_ps.bin", (char*)&buf[0], 48);
	while (1)
	{
		/*
		* uint16_t len = 100;
		int ret = 0;

		buf[0] = index % 127;
		index++;

		{
			int sendRet = tcpClient.Send(buf, len);
			printf("sendRet:%d len:%d \n", sendRet, len);
		}
		*/

		//printf("######### ret:%d seq:%d ssrc:%x\n", ret,header.sequenceNumber, header.ssrc);

		uint16_t len = 0;
		int ret = 0;

		ret = ReadFile::GetInstans().RFile((char*)"tcp_ps.bin", (char*)&buf[0], 2);

		uint16_t* p = (uint16_t*)buf;
		len = *p;
		len = swap16(len);
		if (ret <= 0)
		{
			break;
		}
		ret = ReadFile::GetInstans().RFile((char*)"tcp_ps.bin", (char*)&buf[2], len);
		if (ret <= 0)
		{
			break;
		}
		RTPHeader header;
		bool ok = rtpParse(header, (const void*)&buf[2], len);

		//if (header.sequenceNumber - lastSeq != 1)
		{
			printf("#########  ***** seqNum:%d lastSeq:%d lossNum:%d ssrc:%x %d\n", header.sequenceNumber, lastSeq, header.sequenceNumber - lastSeq, header.ssrc, header.ssrc);

		}
		lastSeq = header.sequenceNumber;


		//printf("######### ret:%d seq:%d ssrc:%x\n", ret,header.sequenceNumber, header.ssrc);


	}
	return 0;
}
